<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>C#HTTP常用方法 | 苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="CSharp HTTP常用方法   CSharp HTTP常用方法 get请求基本方法 Post请求 Http下载文件 post上传文件和键值对 Http服务       get请求基本方法123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657">
<meta property="og:type" content="article">
<meta property="og:title" content="C#HTTP常用方法">
<meta property="og:url" content="http://dontworryneedmoney.gitee.io/guolianbo/2019/09/04/dontworry/%E6%9D%82%E9%A1%B9/C#HTTP%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/index.html">
<meta property="og:site_name" content="苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒">
<meta property="og:description" content="CSharp HTTP常用方法   CSharp HTTP常用方法 get请求基本方法 Post请求 Http下载文件 post上传文件和键值对 Http服务       get请求基本方法123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2019-09-03T17:42:53.000Z">
<meta property="article:modified_time" content="2019-11-10T08:28:53.954Z">
<meta property="article:author" content="worry dont">
<meta property="article:tag" content="杂项">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/guolianbo/atom.xml" title="苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/guolianbo/css/style.css">

<meta name="generator" content="Hexo 4.2.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/guolianbo/" id="logo">苟有恒 何必三更起五更眠 最无益 莫过一日曝十日寒</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/guolianbo/">Home</a>
        
          <a class="main-nav-link" href="/guolianbo/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/guolianbo/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://dontworryneedmoney.gitee.io/guolianbo"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="ejs-dontworry/杂项/C#HTTP常用方法" class="article article-type-ejs" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/guolianbo/2019/09/04/dontworry/%E6%9D%82%E9%A1%B9/C#HTTP%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/" class="article-date">
  <time datetime="2019-09-03T17:42:53.000Z" itemprop="datePublished">2019-09-04</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      C#HTTP常用方法
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h1 id="CSharp-HTTP常用方法"><a href="#CSharp-HTTP常用方法" class="headerlink" title="CSharp HTTP常用方法"></a>CSharp HTTP常用方法</h1><!-- TOC -->

<ul>
<li><a href="#csharp-http常用方法">CSharp HTTP常用方法</a><ul>
<li><a href="#get请求基本方法">get请求基本方法</a></li>
<li><a href="#post请求">Post请求</a></li>
<li><a href="#http下载文件">Http下载文件</a></li>
<li><a href="#post上传文件和键值对">post上传文件和键值对</a></li>
<li><a href="#http服务">Http服务</a></li>
</ul>
</li>
</ul>
<!-- /TOC -->


<h2 id="get请求基本方法"><a href="#get请求基本方法" class="headerlink" title="get请求基本方法"></a>get请求基本方法</h2><figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> 发送Get请求</span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="url"&gt;</span>地址<span class="doctag">&lt;/param&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="dic"&gt;</span>请求参数定义<span class="doctag">&lt;/param&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;returns&gt;</span><span class="doctag">&lt;/returns&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">string</span> <span class="title">Get</span>(<span class="params"><span class="keyword">string</span> url, Dictionary&lt;<span class="keyword">string</span>, <span class="keyword">string</span>&gt; dic</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">string</span> result = <span class="string">""</span>;</span><br><span class="line">    StringBuilder builder = <span class="keyword">new</span> StringBuilder();</span><br><span class="line">    builder.Append(url);</span><br><span class="line">    <span class="keyword">if</span> (dic.Count &gt; <span class="number">0</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        builder.Append(<span class="string">"?"</span>);</span><br><span class="line">        <span class="keyword">int</span> i = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">foreach</span> (<span class="keyword">var</span> item <span class="keyword">in</span> dic)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="keyword">if</span> (i &gt; <span class="number">0</span>)</span><br><span class="line">            &#123; builder.Append(<span class="string">"&amp;"</span>); &#125;</span><br><span class="line">            builder.AppendFormat(<span class="string">"&#123;0&#125;=&#123;1&#125;"</span>, item.Key, item.Value);</span><br><span class="line">            i++;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    HttpWebRequest req = (HttpWebRequest)WebRequest.Create(builder.ToString());</span><br><span class="line">    <span class="comment">//添加参数</span></span><br><span class="line">    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();</span><br><span class="line">    Stream stream = resp.GetResponseStream();</span><br><span class="line">    <span class="keyword">try</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">//获取内容</span></span><br><span class="line">        <span class="keyword">using</span> (StreamReader reader = <span class="keyword">new</span> StreamReader(stream))</span><br><span class="line">        &#123;</span><br><span class="line">            result = reader.ReadToEnd();</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">finally</span></span><br><span class="line">    &#123;</span><br><span class="line">        stream.Close();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> result;</span><br><span class="line">&#125;</span><br><span class="line">```  </span><br><span class="line"></span><br><span class="line"><span class="meta">## Post请求</span></span><br><span class="line"></span><br><span class="line">```CSharp</span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> 创建POST方式的HTTP请求</span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> HttpWebResponse <span class="title">CreatePostHttpResponse</span>(<span class="params"><span class="keyword">string</span> url, IDictionary&lt;<span class="keyword">string</span>, <span class="keyword">string</span>&gt; parameters,</span></span></span><br><span class="line"><span class="function"><span class="params">        <span class="keyword">int</span> timeout, <span class="keyword">string</span> userAgent, CookieCollection cookies</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    HttpWebRequest request = <span class="literal">null</span>;</span><br><span class="line">    <span class="comment">//如果是发送HTTPS请求</span></span><br><span class="line">    <span class="keyword">if</span> (url.StartsWith(<span class="string">"https"</span>, StringComparison.OrdinalIgnoreCase))</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="comment">//ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);</span></span><br><span class="line">        request = WebRequest.Create(url) <span class="keyword">as</span> HttpWebRequest;</span><br><span class="line">        <span class="comment">//request.ProtocolVersion = HttpVersion.Version10;</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        request = WebRequest.Create(url) <span class="keyword">as</span> HttpWebRequest;</span><br><span class="line">    &#125;</span><br><span class="line">    request.Method = <span class="string">"POST"</span>;</span><br><span class="line">    request.ContentType = <span class="string">"application/x-www-form-urlencoded"</span>;</span><br><span class="line">    <span class="comment">//设置代理UserAgent和超时</span></span><br><span class="line">    <span class="comment">//request.UserAgent = userAgent;</span></span><br><span class="line">    <span class="comment">//request.Timeout = timeout;</span></span><br><span class="line">    <span class="keyword">if</span> (cookies != <span class="literal">null</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        request.CookieContainer = <span class="keyword">new</span> CookieContainer();</span><br><span class="line">        request.CookieContainer.Add(cookies);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//发送POST数据</span></span><br><span class="line">    <span class="keyword">if</span> (!(parameters == <span class="literal">null</span> || parameters.Count == <span class="number">0</span>))</span><br><span class="line">    &#123;</span><br><span class="line">        StringBuilder buffer = <span class="keyword">new</span> StringBuilder();</span><br><span class="line">        <span class="keyword">int</span> i = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">foreach</span> (<span class="keyword">string</span> key <span class="keyword">in</span> parameters.Keys)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="keyword">if</span> (i &gt; <span class="number">0</span>)</span><br><span class="line">            &#123;</span><br><span class="line">                buffer.AppendFormat(<span class="string">"&amp;&#123;0&#125;=&#123;1&#125;"</span>, key, parameters[key]);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">else</span></span><br><span class="line">            &#123;</span><br><span class="line">                buffer.AppendFormat(<span class="string">"&#123;0&#125;=&#123;1&#125;"</span>, key, parameters[key]);</span><br><span class="line">                i++;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">byte</span>[] data = Encoding.ASCII.GetBytes(buffer.ToString());</span><br><span class="line">        <span class="keyword">using</span> (Stream stream = request.GetRequestStream())</span><br><span class="line">        &#123;</span><br><span class="line">            stream.Write(data, <span class="number">0</span>, data.Length);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">string</span>[] values = request.Headers.GetValues(<span class="string">"Content-Type"</span>);</span><br><span class="line">    <span class="keyword">return</span> request.GetResponse() <span class="keyword">as</span> HttpWebResponse;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> 获取请求的数据</span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">string</span> <span class="title">GetResponseString</span>(<span class="params">HttpWebResponse webresponse</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">using</span> (Stream s = webresponse.GetResponseStream())</span><br><span class="line">    &#123;</span><br><span class="line">        StreamReader reader = <span class="keyword">new</span> StreamReader(s, Encoding.UTF8);</span><br><span class="line">        <span class="keyword">return</span> reader.ReadToEnd();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Http下载文件"><a href="#Http下载文件" class="headerlink" title="Http下载文件"></a>Http下载文件</h2><figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> http下载文件</span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="url"&gt;</span>下载文件地址<span class="doctag">&lt;/param&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="path"&gt;</span>文件存放地址，包含文件名<span class="doctag">&lt;/param&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;returns&gt;</span><span class="doctag">&lt;/returns&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">bool</span> <span class="title">HttpDownload</span>(<span class="params"><span class="keyword">string</span> url, <span class="keyword">string</span> path</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">string</span> tempPath = System.IO.Path.GetDirectoryName(path) + <span class="string">@"\temp"</span>;</span><br><span class="line">    System.IO.Directory.CreateDirectory(tempPath);  <span class="comment">//创建临时文件目录</span></span><br><span class="line">    <span class="keyword">string</span> tempFile = tempPath + <span class="string">@"\"</span> + System.IO.Path.GetFileName(path) + <span class="string">".temp"</span>; <span class="comment">//临时文件</span></span><br><span class="line">    <span class="keyword">if</span> (System.IO.File.Exists(tempFile))</span><br><span class="line">    &#123;</span><br><span class="line">        System.IO.File.Delete(tempFile);    <span class="comment">//存在则删除</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">try</span></span><br><span class="line">    &#123;</span><br><span class="line">        FileStream fs = <span class="keyword">new</span> FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);</span><br><span class="line">        <span class="comment">// 设置参数</span></span><br><span class="line">        HttpWebRequest request = WebRequest.Create(url) <span class="keyword">as</span> HttpWebRequest;</span><br><span class="line">        <span class="comment">//发送请求并获取相应回应数据</span></span><br><span class="line">        HttpWebResponse response = request.GetResponse() <span class="keyword">as</span> HttpWebResponse;</span><br><span class="line">        <span class="comment">//直到request.GetResponse()程序才开始向目标网页发送Post请求</span></span><br><span class="line">        Stream responseStream = response.GetResponseStream();</span><br><span class="line">        <span class="comment">//创建本地文件写入流</span></span><br><span class="line">        <span class="comment">//Stream stream = new FileStream(tempFile, FileMode.Create);</span></span><br><span class="line">        <span class="keyword">byte</span>[] bArr = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">1024</span>];</span><br><span class="line">        <span class="keyword">int</span> size = responseStream.Read(bArr, <span class="number">0</span>, (<span class="keyword">int</span>)bArr.Length);</span><br><span class="line">        <span class="keyword">while</span> (size &gt; <span class="number">0</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="comment">//stream.Write(bArr, 0, size);</span></span><br><span class="line">            fs.Write(bArr, <span class="number">0</span>, size);</span><br><span class="line">            size = responseStream.Read(bArr, <span class="number">0</span>, (<span class="keyword">int</span>)bArr.Length);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">//stream.Close();</span></span><br><span class="line">        fs.Close();</span><br><span class="line">        responseStream.Close();</span><br><span class="line">        System.IO.File.Move(tempFile, path);</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">true</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">catch</span> (Exception ex)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="keyword">return</span> <span class="literal">false</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="post上传文件和键值对"><a href="#post上传文件和键值对" class="headerlink" title="post上传文件和键值对"></a>post上传文件和键值对</h2><figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">string</span> <span class="title">HttpPostData</span>(<span class="params"><span class="keyword">string</span> url, <span class="keyword">string</span> id, <span class="keyword">string</span> filePath</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">string</span> ip = GetLocalIp();</span><br><span class="line">    <span class="keyword">string</span> taskId = id;</span><br><span class="line">    <span class="keyword">string</span> fileName = filePath;</span><br><span class="line">    <span class="keyword">byte</span>[] fileContentByte = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">1024</span> * <span class="number">1024</span>]; <span class="comment">// 文件内容二进制</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">region</span> 将文件转成二进制</span></span><br><span class="line">    FileStream fs = <span class="keyword">new</span> FileStream(filePath, FileMode.Open, FileAccess.Read);</span><br><span class="line">    fileContentByte = <span class="keyword">new</span> <span class="keyword">byte</span>[fs.Length]; <span class="comment">// 二进制文件</span></span><br><span class="line">    fs.Read(fileContentByte, <span class="number">0</span>, Convert.ToInt32(fs.Length));</span><br><span class="line">    fs.Close();</span><br><span class="line">    <span class="meta">#<span class="meta-keyword">endregion</span></span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">region</span> 定义请求体中的内容 并转成二进制</span></span><br><span class="line">    <span class="keyword">string</span> boundary = <span class="string">"---------------"</span> + DateTime.Now.Ticks.ToString(<span class="string">"x"</span>);</span><br><span class="line">    <span class="keyword">string</span> Enter = <span class="string">"\r\n"</span>;</span><br><span class="line">    <span class="keyword">string</span> localIp = <span class="string">"--"</span> + boundary + Enter</span><br><span class="line">                        + <span class="string">"Content-Disposition: form-data; name=\"ip\""</span> + Enter + Enter</span><br><span class="line">                        + ip + Enter;</span><br><span class="line">    <span class="keyword">string</span> fileContentStr = <span class="string">"--"</span> + boundary + Enter</span><br><span class="line">                            + <span class="string">"Content-Type:application/octet-stream"</span> + Enter</span><br><span class="line">                            + <span class="string">"Content-Disposition: form-data; name=\"file\"; filename=\""</span> + fileName + <span class="string">"\""</span> + Enter + Enter;</span><br><span class="line">    <span class="keyword">string</span> taskIdStr = Enter + <span class="string">"--"</span> + boundary + Enter</span><br><span class="line">                        + <span class="string">"Content-Disposition: form-data; name=\"id\""</span> + Enter + Enter</span><br><span class="line">                        + taskId;</span><br><span class="line">    <span class="keyword">var</span> localIpByte = Encoding.UTF8.GetBytes(localIp);<span class="comment">//ip所有字符串二进制</span></span><br><span class="line">    <span class="keyword">var</span> fileContentStrByte = Encoding.UTF8.GetBytes(fileContentStr);<span class="comment">//fileContent一些名称等信息的二进制（不包含文件本身）</span></span><br><span class="line">    <span class="keyword">var</span> taskIdByte = Encoding.UTF8.GetBytes(taskIdStr);<span class="comment">//id所有字符串二进制</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">endregion</span></span></span><br><span class="line">    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);</span><br><span class="line">    request.Method = <span class="string">"POST"</span>;</span><br><span class="line">    request.ContentType = <span class="string">"multipart/form-data;boundary="</span> + boundary;</span><br><span class="line">    Stream myRequestStream = request.GetRequestStream();<span class="comment">//定义请求流</span></span><br><span class="line">    <span class="meta">#<span class="meta-keyword">region</span></span></span><br><span class="line">    myRequestStream.Write(localIpByte, <span class="number">0</span>, localIpByte.Length);</span><br><span class="line">    myRequestStream.Write(fileContentStrByte, <span class="number">0</span>, fileContentStrByte.Length);</span><br><span class="line">    myRequestStream.Write(fileContentByte, <span class="number">0</span>, fileContentByte.Length);</span><br><span class="line">    myRequestStream.Write(taskIdByte, <span class="number">0</span>, taskIdByte.Length);</span><br><span class="line">    <span class="meta">#<span class="meta-keyword">endregion</span></span></span><br><span class="line">    HttpWebResponse response = (HttpWebResponse)request.GetResponse();<span class="comment">//发送</span></span><br><span class="line">    Stream myResponseStream = response.GetResponseStream();<span class="comment">//获取返回值</span></span><br><span class="line">    StreamReader myStreamReader = <span class="keyword">new</span> StreamReader(myResponseStream, Encoding.GetEncoding(<span class="string">"utf-8"</span>));</span><br><span class="line">    <span class="keyword">string</span> retString = myStreamReader.ReadToEnd();</span><br><span class="line">    myStreamReader.Close();</span><br><span class="line">    myResponseStream.Close();</span><br><span class="line">    File.Delete(filePath);<span class="comment">// 上传后删除文件</span></span><br><span class="line">    <span class="keyword">return</span> retString;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="Http服务"><a href="#Http服务" class="headerlink" title="Http服务"></a>Http服务</h2><figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">StartHttpServer</span>(<span class="params">Action&lt;<span class="keyword">string</span>&gt; showMsg</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    _httpPostRequest.Prefixes.Add(IMPORT_CAD_URL);</span><br><span class="line">    _httpPostRequest.Start();</span><br><span class="line">    Thread ThrednHttpPostRequest = <span class="keyword">new</span> Thread(<span class="keyword">new</span> ThreadStart(() =&gt; httpPostRequestHandle(showMsg)));</span><br><span class="line">    ThrednHttpPostRequest.Start();</span><br><span class="line">&#125;</span><br><span class="line">               </span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> 处理Post和get请求</span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;/summary&gt;</span></span></span><br><span class="line"><span class="comment"><span class="doctag">///</span> <span class="doctag">&lt;param name="showMsg"&gt;</span><span class="doctag">&lt;/param&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">httpPostRequestHandle</span>(<span class="params">Action&lt;<span class="keyword">string</span>&gt; showMsg</span>)</span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="keyword">while</span> (<span class="literal">true</span>)</span><br><span class="line">    &#123;</span><br><span class="line">        HttpListenerContext requestContext = _httpPostRequest.GetContext();</span><br><span class="line">        Thread threadsub = <span class="keyword">new</span> Thread(<span class="keyword">new</span> ParameterizedThreadStart((requestcontext) =&gt;</span><br><span class="line">        &#123;</span><br><span class="line">            HttpListenerContext request = (HttpListenerContext) requestcontext;</span><br><span class="line">            <span class="keyword">string</span> userName = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">string</span> password = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">string</span> suffix = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">string</span> FileID = <span class="string">""</span>;</span><br><span class="line">            <span class="keyword">if</span> (</span><br><span class="line">                request.Request.HttpMethod == <span class="string">"POST"</span>)</span><br><span class="line">            &#123;</span><br><span class="line">                showMsg(<span class="string">"Post"</span>);</span><br><span class="line">                <span class="comment">//获取Post请求中的参数和值帮助类</span></span><br><span class="line">                HttpListenerPostParaHelper httppost = <span class="keyword">new</span> HttpListenerPostParaHelper(request);</span><br><span class="line">                <span class="comment">//获取Post过来的参数和数据</span></span><br><span class="line">                List&lt;HttpListenerPostValue&gt; lst = httppost.GetHttpListenerPostValue();</span><br><span class="line">                <span class="comment">//使用方法</span></span><br><span class="line">                <span class="keyword">foreach</span> (<span class="keyword">var</span> key <span class="keyword">in</span> lst)</span><br><span class="line">                &#123;</span><br><span class="line">                    <span class="keyword">if</span> (key.type == <span class="number">0</span>)</span><br><span class="line">                    &#123;</span><br><span class="line">                        <span class="keyword">string</span> <span class="keyword">value</span> = Encoding.UTF8.GetString(key.datas).Replace(<span class="string">"\r\n"</span>, <span class="string">""</span>);</span><br><span class="line">                        <span class="keyword">if</span> (key.name == <span class="string">"username"</span>)</span><br><span class="line">                        &#123;</span><br><span class="line">                            userName = <span class="keyword">value</span>;</span><br><span class="line">                            showMsg(key.name + <span class="string">": "</span> + <span class="keyword">value</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="keyword">if</span> (key.name == <span class="string">"password"</span>)</span><br><span class="line">                        &#123;</span><br><span class="line">                            password = <span class="keyword">value</span>;</span><br><span class="line">                            showMsg(key.name + <span class="string">": "</span> + <span class="keyword">value</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="keyword">if</span> (key.name == <span class="string">"suffix"</span>)</span><br><span class="line">                        &#123;</span><br><span class="line">                            suffix = <span class="keyword">value</span>;</span><br><span class="line">                            showMsg(key.name + <span class="string">": "</span> + <span class="keyword">value</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                        <span class="keyword">if</span> (key.name == <span class="string">"file"</span>)</span><br><span class="line">                        &#123;</span><br><span class="line">                            <span class="comment">//                                    FileID = value;</span></span><br><span class="line">                            <span class="comment">//                                    showMsg(key.name + ": " + value);</span></span><br><span class="line">                            WriteByteToFile(key.datas, <span class="string">@"D:\inCADFile\test.dwg"</span>);</span><br><span class="line">                            showMsg(<span class="string">"Done!"</span>);</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                    <span class="keyword">if</span> (key.type == <span class="number">1</span>)</span><br><span class="line">                    &#123;</span><br><span class="line">                        <span class="keyword">string</span> fileName = <span class="string">"test.dwg"</span>;</span><br><span class="line">                        <span class="keyword">string</span> directory = <span class="string">@"D:\inCADFile\"</span>;<span class="comment">//AppDomain.CurrentDomain.BaseDirectory</span></span><br><span class="line">                        <span class="comment">//                                string fileName = request.Request.QueryString["FileName"];</span></span><br><span class="line">                        <span class="keyword">if</span> (!<span class="keyword">string</span>.IsNullOrEmpty(fileName))</span><br><span class="line">                        &#123;</span><br><span class="line">                            <span class="keyword">string</span> filePath = directory +</span><br><span class="line">                                                DateTime.Now.ToString(<span class="string">"yyMMdd_HHmmss_ffff"</span>) +</span><br><span class="line">                                                Path.GetExtension(fileName).ToLower();</span><br><span class="line">                            <span class="keyword">if</span> (key.name == <span class="string">"file"</span>)</span><br><span class="line">                            &#123;</span><br><span class="line">                                FileStream fs = <span class="keyword">new</span> FileStream(filePath, FileMode.Create);</span><br><span class="line">                                fs.Write(key.datas, <span class="number">0</span>, key.datas.Length);</span><br><span class="line">                                fs.Close();</span><br><span class="line">                                fs.Dispose();</span><br><span class="line">                            &#125;</span><br><span class="line">                        &#125;</span><br><span class="line">                    &#125;</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="keyword">if</span> (</span><br><span class="line">                request.Request.HttpMethod == <span class="string">"GET"</span>)</span><br><span class="line">            &#123;</span><br><span class="line">                showMsg(<span class="string">"GET"</span>);</span><br><span class="line">                FileID = request.Request.QueryString[<span class="string">"FileID"</span>];</span><br><span class="line">                suffix = request.Request.QueryString[<span class="string">"suffix"</span>];</span><br><span class="line">                password = request.Request.QueryString[<span class="string">"password"</span>];</span><br><span class="line">                userName = request.Request.QueryString[<span class="string">"username"</span>];</span><br><span class="line">                showMsg(userName);</span><br><span class="line">                showMsg(password);</span><br><span class="line">                showMsg(suffix);</span><br><span class="line">                showMsg(FileID);</span><br><span class="line">            &#125;</span><br><span class="line">            <span class="comment">//Response</span></span><br><span class="line">            request.Response.StatusCode = <span class="number">200</span>;</span><br><span class="line">            request.Response.Headers.Add(<span class="string">"Access-Control-Allow-Origin"</span>, <span class="string">"*"</span>);</span><br><span class="line">            request.Response.ContentType = <span class="string">"application/json"</span>;</span><br><span class="line">            requestContext.Response.ContentEncoding = Encoding.UTF8;</span><br><span class="line">            <span class="keyword">byte</span>[] buffer =</span><br><span class="line">                System.Text.Encoding.UTF8.GetBytes(</span><br><span class="line">                    Newtonsoft.Json.JsonConvert.SerializeObject(<span class="keyword">new</span> &#123;success = <span class="string">"true"</span>, msg = <span class="string">"提交成功"</span>&#125;));</span><br><span class="line">            request.Response.ContentLength64 = buffer.Length;</span><br><span class="line">            <span class="keyword">var</span> output = request.Response.OutputStream;</span><br><span class="line">            output.Write(buffer, <span class="number">0</span>, buffer.Length);</span><br><span class="line">            output.Close();</span><br><span class="line">        &#125;));</span><br><span class="line">        threadsub.Start(requestContext);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://dontworryneedmoney.gitee.io/guolianbo/2019/09/04/dontworry/%E6%9D%82%E9%A1%B9/C#HTTP%E5%B8%B8%E7%94%A8%E6%96%B9%E6%B3%95/" data-id="ckb6hw6sn004bjcn20v76b578" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" rel="tag">杂项</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/guolianbo/2019/09/04/dontworry/%E6%9D%82%E9%A1%B9/CAD%E4%BA%8C%E6%AC%A1%E5%BC%80%E5%8F%91%E5%9F%BA%E7%A1%80/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          CAD二次开发基础
        
      </div>
    </a>
  
  
    <a href="/guolianbo/2019/09/04/dontworry/Unity3d/%E5%B8%A6%E9%A2%9C%E8%89%B2%E7%9A%84%E8%B0%83%E8%AF%95log/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">带颜色的调试log</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/guolianbo/categories/%E9%9A%8F%E7%AC%94/">随笔</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/Algorithm/" rel="tag">Algorithm</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/Unity3d/" rel="tag">Unity3d</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" rel="tag">杂项</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E6%B6%88%E9%98%B2/" rel="tag">消防</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E7%94%B3%E8%AE%BA/" rel="tag">申论</a></li><li class="tag-list-item"><a class="tag-list-link" href="/guolianbo/tags/%E9%9A%8F%E7%AC%94/" rel="tag">随笔</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/guolianbo/tags/Algorithm/" style="font-size: 14px;">Algorithm</a> <a href="/guolianbo/tags/Unity3d/" style="font-size: 12px;">Unity3d</a> <a href="/guolianbo/tags/%E6%9D%82%E9%A1%B9/" style="font-size: 18px;">杂项</a> <a href="/guolianbo/tags/%E6%B6%88%E9%98%B2/" style="font-size: 16px;">消防</a> <a href="/guolianbo/tags/%E7%94%B3%E8%AE%BA/" style="font-size: 10px;">申论</a> <a href="/guolianbo/tags/%E9%9A%8F%E7%AC%94/" style="font-size: 20px;">随笔</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/06/">June 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/05/">May 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/04/">April 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/03/">March 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/02/">February 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2020/01/">January 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/09/">September 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/guolianbo/archives/2019/06/">June 2019</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/guolianbo/2020/06/08/dontworry/Unity3d/IObserver%E5%92%8CIObservable%E5%92%8CIDisposable/">IObserver和IObservable和IDisposable</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/28/dontworry/%E6%9D%82%E9%A1%B9/javascript%E7%9A%84%E6%9C%AC%E8%B4%A8/">javascript的本质</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/27/dontworry/%E6%9D%82%E9%A1%B9/%E5%8D%8F%E7%A8%8B%E7%9A%84%E5%8E%9F%E7%90%86/">协程的原理</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/20/dontworry/%E6%9D%82%E9%A1%B9/linux%E4%B8%8B%E7%9A%84nginx%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C/">linux下的nginx的基本操作</a>
          </li>
        
          <li>
            <a href="/guolianbo/2020/05/15/dontworry/%E6%9D%82%E9%A1%B9/%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0%E5%8A%A8%E8%AF%8D/">常用函数动词</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 worry dont<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/guolianbo/" class="mobile-nav-link">Home</a>
  
    <a href="/guolianbo/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/guolianbo/fancybox/jquery.fancybox.css">

  
<script src="/guolianbo/fancybox/jquery.fancybox.pack.js"></script>




<script src="/guolianbo/js/script.js"></script>




  </div>
</body>
</html>